]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
animations: Stop syncing size manually
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 9 Jun 2023 18:12:15 +0000 (20:12 +0200)
committerMarge Bot <marge-bot@gnome.org>
Wed, 5 Jul 2023 10:36:14 +0000 (10:36 +0000)
The returned slice actors are now set up to fill their parent,
accounting for any difference between loaded- and displayed size,
so we can stop syncing the size manually.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2798>

js/ui/animation.js

index 0a784413a7dc3ea2bcaaa4751afe850ae1a26930..b70f8767bdc8fd57a7d2123935e1246e5f734805 100644 (file)
@@ -40,10 +40,6 @@ class Animation extends St.Bin {
         this._frame = 0;
 
         this._loadFile(file, width, height);
-
-        // If the parent changes, we need to re-sync the animation
-        // size
-        this.connect('parent-set', () => this._syncAnimationSize());
     }
 
     play() {
@@ -81,11 +77,12 @@ class Animation extends St.Bin {
         let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
         this._animations = textureCache.load_sliced_image(file, width, height,
             scaleFactor, resourceScale,
-            () => this._syncAnimationSize());
+            () => this._loadFinished());
         this._animations.set({
             x_align: Clutter.ActorAlign.CENTER,
             y_align: Clutter.ActorAlign.CENTER,
         });
+
         this.set_child(this._animations);
 
         if (wasPlaying)
@@ -109,19 +106,10 @@ class Animation extends St.Bin {
         return GLib.SOURCE_CONTINUE;
     }
 
-    _syncAnimationSize() {
+    _loadFinished() {
         this._isLoaded = this._animations.get_n_children() > 0;
 
-        // this.get_size() can't be called without a parent
-        if (!this._isLoaded || !this.get_parent())
-            return;
-
-        let [width, height] = this.get_size();
-
-        for (let i = 0; i < this._animations.get_n_children(); ++i)
-            this._animations.get_child_at_index(i).set_size(width, height);
-
-        if (this._isPlaying)
+        if (this._isLoaded && this._isPlaying)
             this.play();
     }